update sos set sos.LocationCode = pur.LocationCode 
from Purchase as pur inner join StockOS as sos on pur.branch= sos.branch and pur.type =sos.type and pur.prefix = sos.prefix and pur.srl = sos.srl
where case when pur.LocationCode = sos.LocationCode then 'y' else 'n' end ='n'


update sos set sos.LocationCode = pur.LocationCode 
from Purchase as pur inner join StockExcise as sos on pur.branch= sos.branch and pur.type =sos.type and pur.prefix = sos.prefix and pur.srl = sos.srl
where case when pur.LocationCode = sos.LocationCode then 'y' else 'n' end ='n'


update sos set sos.LocationCode = pur.LocationCode 
from Purchase as pur inner join SuppExciseDet   as sos on pur.branch= sos.branch and pur.type =sos.type and pur.prefix = sos.prefix and pur.srl = sos.srl
where case when pur.LocationCode = sos.LocationCode then 'y' else 'n' end ='n'


update sos set sos.LocationCode = pur.LocationCode 
from Purchase as pur inner join StockExtraCost  as sos on pur.branch= sos.branch and pur.type =sos.type and pur.prefix = sos.prefix and pur.srl = sos.srl
where case when pur.LocationCode = sos.LocationCode then 'y' else 'n' end ='n'


update sos set sos.LocationCode = pur.LocationCode 
from Purchase as pur inner join (select * from Purchase  where type ='boe')  as sos on pur.branch= sos.branch and pur.type =sos.atype and pur.prefix = sos.aprefix and pur.srl = sos.aSerial 
where  case when pur.LocationCode = sos.LocationCode then 'y' else 'n' end ='n'

